$().ready(function() {
	validateRule();
	$("#brandType").val($("#typeHidden").val());
	$("#enterpriseScale").val($("#enterpriseScaleHidden").val());
});


//上传品牌照片
layui.use('upload', function () {
	var upload = layui.upload;
	upload.render({
		elem: '#btnAdd',
		url: '/common/sysFile/upload',
		accept: 'images', //只允许上传图片
		acceptMime: 'image/*', //只筛选图片
		size:10240,
		done: function (r) {
			$("#brandImg").val(r.data);
			$("#brandImgs").attr("src",r.data)

		},
		error: function (r) {
			layer.msg(r.msg);
		}
	});
});

$.validator.setDefaults({
	submitHandler : function() {
		update();
	}
});
function update() {
	$.ajax({
		cache : true,
		type : "POST",
		url : "/jzweb/sysBrand/update",
		data : $('#signupForm').serialize(),// 你的formid
		async : false,
		error : function(request) {
			parent.layer.alert("Connection error");
		},
		success : function(data) {
			if (data.code == 0) {
				parent.layer.msg("操作成功");
				parent.reLoad();
				var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
				parent.layer.close(index);

			} else {
				parent.layer.alert(data.msg)
			}

		}
	});

}
function validateRule() {
	var icon = "<i class='fa fa-times-circle'></i> ";
	$("#signupForm").validate({
		rules : {
			name : {
				required : true
			}
		},
		messages : {
			name : {
				required : icon + "请输入名字"
			}
		}
	})
}